<?php
namespace app\index\controller;

use app\admin\model\Friend;
use app\admin\model\Lunbo;
use think\Controller;
use app\common\model\Category;
use categoryclass\Categoryclass;

class CommonController extends Controller
{
    protected $category = null;
    public function _initialize()
    {
        parent::_initialize();

        //1.取出配置项内容  -- 在extra/web.php中
        $config = config('web');
        $this->assign('config', $config);
        //2.导航栏
        /*$cate = Category::where('parent_id','0')->order('sort_order desc')->select();
        $category_list = Categoryclass::orm_catesorts($cate);

        $this->assign('category_list', $category_list);
        //3.轮播图
        $lunbo = (new Lunbo())->_list();
        $this->assign('lunbo', $lunbo);*/
        //5. 友情链接
        /*$friend = (new Friend())->all_list();
        $this->assign('friend', $friend);*/
    }

    /**
     *  公共方法 ： 取出block 表的 序列号数据
     * @param string $type
     * @return mixed
     */
    public function index_block($type = '')
    {
        if (empty($type)) return '';
        //获取区块内容
        $content = \think\Db::name('block')->field('content')->where('type', $type)->find();
        //反序列化 数据
        return unserialize($content['content']);
    }
}
